#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5 +5,L=1e6 + 5;
inline int read(){
    int x=0,y=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')y=-1;c=getchar();}
    while(isdigit(c)){x=x*10+c-48;c=getchar();}
    return x*y;
}
int T,n,m,l,mxv;
int d[N],vv[N],a[N],sum[L],ans,ans1,f[N],t[N],tot,nf[N],nt[N],tot2,hutao;
bool vis[N],flagAB,flagc,keli;
int mk[N],kkk[100];
int p[N],cnt[N];
vector<int> v[L],g[N];
void init(){
    hutao=0;
    flagAB=flagc=1;
    tot2=0;
    for(int i=1;i<=l+1;++i){
        sum[i]=0;
    }
    for(int i=1;i<=n;++i){
        mk[i]=0;
    }
    for(int i=1;i<=m;++i){
        vis[p[i]]=0;
        g[i].clear();
    }
    ans=0,ans1=0;
}
void work(int cur,int curv,int cura){
    if(curv>mxv&&cura>=0){
        //cout<<cur<<" "<<l+1<<endl;
        v[cur].push_back(l+1);
        f[++tot]=cur,t[tot]=l;
        sum[cur]++;
        sum[l+1]--;
        return ;
    }
    if(curv<=mxv&&cura<=0){
        return ;
    }
    double dis=0;
    double dis2=0;
    if(curv>mxv){
        dis=abs((mxv*mxv-curv*curv)/(cura*2));
        dis2=dis-(int)dis;
        if(dis2==0.0){
            sum[cur]++;
            f[++tot]=cur,t[tot]=(int)dis+cur-1;
            sum[min(l+1,(int)dis+cur)]--;
            return ;
        }
        sum[cur]++;
        f[++tot]=cur,t[tot]=(int)dis+cur;
        sum[min(l+1,(int)dis+cur+1)]--;
        return ;
    }
    dis=abs((mxv*mxv-curv*curv)/(cura*2));
    f[++tot]=dis+cur+1;
    t[tot]=l;
    dis2=dis-(int)dis;
    sum[min((int)dis+1+cur,l+1)]++;
    sum[l+1]--;
    return ;
}
void bfs(){
    for(int i=1;i<=n;++i){
        if(t[i]==l&&f[i]<=p[m]){
            ans1++;
        }
    }
}
bool check(int tott){
    int keqin=0;
    for(int i=1;i<=hutao;++i){
        kkk[i]=0;
    }
    for(int i=0;i<tott;++i){
        for(int j=0;j<g[cnt[i]].size();++j){
            if(!kkk[g[cnt[i]][j]]){
                keqin++;
                kkk[g[cnt[i]][j]]=1;
            }
        }
    }
    return keqin>=hutao;
}
void dfind(int x,int nahida,int cur){
    if(x==tot2+1){
        if(nahida!=cur){
            return ;
        }
        if(check(nahida)){
            keli=1;
        }
        return ;
    }
    if(nahida>cur){
        return ;
    }
    if(n-x+1<cur-nahida){
        return ;
    }
    cnt[nahida]=x;
    dfind(x+1,nahida+1,cur);
    if(keli){
        return ;
    }
    cnt[nahida]=0;
    dfind(x+1,nahida,cur);
    if(keli){
        return ;
    }
    
}
void genshin(){
    keli=0;
    int s=0;
    for(int i=1;i<=m;++i){
        bool flag=0;
        for(int j=1;j<=n;++j){
            if(f[j]<=p[i]&&t[j]>=p[i]){
                if(!flag){
                    flag=1;
                    tot2++;
                }
                if(!mk[j]){
                    hutao++;
                    mk[j]=hutao;
                }
                g[tot2].push_back(mk[j]);
            }
        }
    }
    if(hutao==0){
        cout<<0<<" "<<m<<endl;
        return ;
    }
    //cout<<"IKAIOI\n";
    for(int i=1;i<=tot2;i++){
        dfind(1,0,i);
        if(keli){
            cout<<hutao<<" "<<m-i<<endl;
            return ;
        }
    }
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    T=read();
    while(T--){
        tot=0;
        init();
        n=read(),m=read(),l=read(),mxv=read();
        for(int i=1;i<=n;++i){
            d[i]=read(),vv[i]=read(),a[i]=read();
            work(d[i],vv[i],a[i]);
            if(a[i]<0){
                flagAB=0;
            }else{
                flagc=0;
            }
        }
        for(int i=1;i<=m;++i){
            p[i]=read();
            vis[p[i]]=1;
        }
        if(flagAB){
            bfs();
            if(ans1==0){
                cout<<0<<" "<<m<<endl;
                continue;
            }
            cout<<ans1<<" "<<m-1<<endl;
            continue;
        }else if(n<=20){
            //cout<<1111<<endl;
            genshin();
        }   
    }
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 ‐2
6 4 ‐4
2 5 8 9 15
*/